package com.addressbook.fw;

import org.openqa.selenium.By;


public class NavigationHelper extends WebDriverHelperBase{
	
	public NavigationHelper(ApplicationManager app) {
		super(app);
	}

	public void MainPage() {		
		if (! onMainPage()) {
			click(By.linkText("groups"));
		}		
	}	
	
	private boolean onMainPage() {
		return driver.findElements(By.id("maintable")).size() > 0;
	}

	public void GroupList() {
		if (! onGroupsPage()) {
			click(By.linkText("groups"));
		}		
	}	
	
	private boolean onGroupsPage() {
		if (driver.getCurrentUrl().contains("/group.php")
				&& driver.findElements(By.name("new")).size() > 0){
			return true;
		}
		return false;
	}

	public void ContactList() {
		click(By.linkText("home"));
	}

	public void AddNewContact() {
		click(By.linkText("add new"));
	}

}
